package com.zhiche.lisa.lspm.controller;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.toolkit.CollectionUtils;
import com.google.common.collect.Lists;
import com.zhiche.lisa.core.enums.CommonEnum;
import com.zhiche.lisa.core.supports.BaseException;
import com.zhiche.lisa.core.supports.RestfulResponse;
import com.zhiche.lisa.core.utils.Account.AccountUtil;
import com.zhiche.lisa.core.utils.Account.JwtAccountVO;
import com.zhiche.lisa.lspm.dao.model.lsp.LspBankAccount;
import com.zhiche.lisa.lspm.dao.model.lsp.LspCard;
import com.zhiche.lisa.lspm.dao.model.lsp.LspInfo;
import com.zhiche.lisa.lspm.dao.model.lsp.bo.AfterAuthLspLineBO;
import com.zhiche.lisa.lspm.dao.model.lsp.bo.LspAuthLineBO;
import com.zhiche.lisa.lspm.dao.model.lsp.bo.LspBlackBO;
import com.zhiche.lisa.lspm.dao.model.lsp.bo.ModifyLspInfoBO;
import com.zhiche.lisa.lspm.dao.model.sys.User;
import com.zhiche.lisa.lspm.dto.ArFundDTO;
import com.zhiche.lisa.lspm.service.lsp.LspBankAccountService;
import com.zhiche.lisa.lspm.service.lsp.LspCardService;
import com.zhiche.lisa.lspm.service.lsp.LspCreateLogService;
import com.zhiche.lisa.lspm.service.lsp.LspInfoService;
import com.zhiche.lisa.lspm.vo.common.CommonVo;
import com.zhiche.lisa.lspm.vo.lsp.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;
import java.util.Objects;

/**
 * 承运商 接口
 *
 * @author lbl
 * @since 2018-05-23
 */
@RestController
@RequestMapping(value = "/lsp")
@Api(value = "/lsp", description = "承运商接口", tags = {"承运商接口"})
public class LspController {

    private static final Logger LOGGER = LoggerFactory.getLogger(LspController.class);

    @Autowired
    private LspInfoService lspInfoService;
    @Autowired
    private LspCardService lspCardService;
    @Autowired
    private LspBankAccountService lspBankAccountService;

    @Autowired
    private LspCreateLogService lspCreateLogService;

    /**
     * 承运商列表
     *
     * @param page
     * @return
     */
    @PostMapping(value = "/lspInfoLine")
    @ApiOperation(value = "获取承运商基础信息列表", notes = "获取承运商基础信息列表", produces = MediaType.APPLICATION_JSON_VALUE, response
            = RestfulResponse.class)
    public RestfulResponse<Page<LspBasicVO>> lspInfoLine(@RequestBody Page<LspInfoLineVO> page, @RequestHeader("Authorization") String authorization) {
        LOGGER.info("LspInfoController.lspInfoLine（获取承运商基础信息列表） params : {} ", page);
        RestfulResponse<Page<LspBasicVO>> result = new RestfulResponse<>(CommonEnum.SUCCESS.getCode(), CommonEnum
                .SUCCESS.getText(), null);
        try {
            Page<LspBasicVO> pageVo = lspInfoService.lspInfoLine(page, authorization);
            result.setData(pageVo);
        } catch (BaseException e) {
            LOGGER.error("LspInfoController.lspInfoLine ERROR... ", e);
            result = new RestfulResponse<>(CommonEnum.ERROR.getCode(), e.getMessage(), null);
        } catch (Exception e) {
            LOGGER.error("LspInfoController.lspInfoLine ERROR... ", e);
            result = new RestfulResponse<>(CommonEnum.ERROR.getCode(), CommonEnum.ERROR.getText(), null);
        }
        return result;
    }

    /**
     * 承运商拉黑列表
     *
     * @param page
     * @return
     */
    @PostMapping(value = "/lspBlackLine")
    @ApiOperation(value = "获取被拉黑的承运商列表", notes = "获取承运商认证列表", produces = MediaType.APPLICATION_JSON_VALUE, response =
            RestfulResponse.class)
    public RestfulResponse<Page<LspBlackLineVO>> lspBlackLine(@RequestBody Page<LspBlackBO> page) {
        LOGGER.info("LspInfoController.lspBlackLine（获取被拉黑的承运商列表） params : {} ", page);
        RestfulResponse<Page<LspBlackLineVO>> result = new RestfulResponse<>(CommonEnum.SUCCESS.getCode(), CommonEnum
                .SUCCESS.getText(), null);
        try {
            Page<LspBlackLineVO> pageVo = lspInfoService.lspBlackLine(page);
            result.setData(pageVo);
        } catch (BaseException e) {
            LOGGER.error("LspInfoController.lspBlackLine ERROR... ", e);
            result = new RestfulResponse<>(CommonEnum.ERROR.getCode(), e.getMessage(), null);
        } catch (Exception e) {
            LOGGER.error("LspInfoController.lspBlackLine ERROR... ", e);
            result = new RestfulResponse<>(CommonEnum.ERROR.getCode(), CommonEnum.ERROR.getText(), null);
        }
        return result;
    }

    @PostMapping(value = "/lspInBlack")
    @ApiOperation(value = "拉黑指定承运商", notes = "拉黑指定承运商", produces = MediaType.APPLICATION_JSON_VALUE, response =
            RestfulResponse.class)
    public RestfulResponse<String> lspInBlack(@RequestBody LspBlackLineVO lineVO) {
        LOGGER.info("LspInfoController.lspInBlack（承运商拉黑） params : {} ", lineVO);
        RestfulResponse<String> result = new RestfulResponse<>(CommonEnum.SUCCESS.getCode(), CommonEnum.SUCCESS
                .getText(), null);
        try {
            lspInfoService.lspInBlack(lineVO.getId(), lineVO.getInlistReason());
        } catch (BaseException e) {
            LOGGER.error("LspInfoController.lspInBlack ERROR... ", e);
            result = new RestfulResponse<>(CommonEnum.ERROR.getCode(), e.getMessage(), null);
        } catch (Exception e) {
            LOGGER.error("LspInfoController.lspInBlack ERROR... ", e);
            result = new RestfulResponse<>(CommonEnum.ERROR.getCode(), CommonEnum.ERROR.getText(), null);
        }
        return result;
    }

    @PostMapping(value = "/lspCleanBlack")
    @ApiOperation(value = "取消指定承运商拉黑", notes = "取消指定承运商拉黑", produces = MediaType.APPLICATION_JSON_VALUE, response =
            RestfulResponse.class)
    public RestfulResponse<String> lspCleanBlack(@RequestBody LspBlackLineVO lineVO) {
        LOGGER.info("LspInfoController.lspCleanBlack（取消承运商拉黑） params : {} ", lineVO);
        RestfulResponse<String> result = new RestfulResponse<>(CommonEnum.SUCCESS.getCode(), CommonEnum.SUCCESS
                .getText(), null);
        try {
            lspInfoService.lspCleanBlack(lineVO.getId(), lineVO.getOutlistReason());
        } catch (BaseException e) {
            LOGGER.error("LspInfoController.lspCleanBlack ERROR... ", e);
            result = new RestfulResponse<>(CommonEnum.ERROR.getCode(), e.getMessage(), null);
        } catch (Exception e) {
            LOGGER.error("LspInfoController.lspCleanBlack ERROR... ", e);
            result = new RestfulResponse<>(CommonEnum.ERROR.getCode(), CommonEnum.ERROR.getText(), null);
        }
        return result;
    }

    /**
     * 承运商认证列表
     *
     * @param page
     * @return
     */
    @PostMapping(value = "/lspAuthLine")
    @ApiOperation(value = "获取承运商认证列表", notes = "获取承运商认证列表", produces = MediaType.APPLICATION_JSON_VALUE, response =
            RestfulResponse.class)
    public RestfulResponse<Page<LspAuthLineVO>> lspAuthLine(@RequestBody Page<LspAuthLineBO> page) {
        LOGGER.info("LspInfoController.lspAuthLine（获取承运商认证列表） params : {} ", page);
        RestfulResponse<Page<LspAuthLineVO>> result = new RestfulResponse<>(CommonEnum.SUCCESS.getCode(), CommonEnum
                .SUCCESS.getText(), null);
        try {
            Page<LspAuthLineVO> pageVo = lspInfoService.lspAuthLine(page);
            result.setData(pageVo);
        } catch (BaseException e) {
            LOGGER.error("LspInfoController.lspAuthLine ERROR... ", e);
            result = new RestfulResponse<>(CommonEnum.ERROR.getCode(), e.getMessage(), null);
        } catch (Exception e) {
            LOGGER.error("LspInfoController.lspAuthLine ERROR... ", e);
            result = new RestfulResponse<>(CommonEnum.ERROR.getCode(), CommonEnum.ERROR.getText(), null);
        }

        return result;
    }

    /**
     * 得到登录账号的承运商(公司)信息
     *
     * @param
     * @return
     */
    @RequestMapping(value = "/getLspInfo", method = RequestMethod.GET)
    @ApiOperation(value = "得到登录账号的承运商(公司)信息", notes = "得到登录账号的承运商(公司)信息",
            produces = MediaType.APPLICATION_JSON_VALUE, response = RestfulResponse.class)
    public RestfulResponse<LspBasicVO> getLonginLspInfo() {
        RestfulResponse<LspBasicVO> result = new RestfulResponse<>(CommonEnum.SUCCESS.getCode(), "success", null);
        try {
            LspBasicVO lspInfo = lspInfoService.getLonginLspInfo();
            result.setData(lspInfo);
        } catch (BaseException be) {
            LOGGER.error("LspController.getLspByTenantId error:{}", be.getMessage());
            result.setMessage(be.getMessage());
            result.setCode(CommonEnum.ERROR.getCode());
        } catch (Exception e) {
            LOGGER.error("LspController.getLspByTenantId error:{}", e.getMessage());
            result.setMessage("系统异常，请稍后再试");
            result.setCode(CommonEnum.ERROR.getCode());
        }
        return result;
    }

    /**
     * 认证后的承运商列表
     *
     * @param page
     * @return
     */
    @PostMapping(value = "/afterAuthLspLine")
    @ApiOperation(value = "获取认证的承运商列表", notes = "获取认证的承运商列表", produces = MediaType.APPLICATION_JSON_VALUE, response =
            RestfulResponse.class)
    public RestfulResponse<Page<AfterAuthLspLineVO>> afterAuthLspLine(@RequestBody Page<AfterAuthLspLineBO> page) {
        LOGGER.info("LspInfoController.afterAuthLspLine（获取认证的承运商列表） params : {} ", page);
        RestfulResponse<Page<AfterAuthLspLineVO>> result = new RestfulResponse<>(CommonEnum.SUCCESS.getCode(),
                CommonEnum.SUCCESS.getText(), null);
        try {
            Page<AfterAuthLspLineVO> pageVo = lspInfoService.afterAuthLspLine(page);
            result.setData(pageVo);
        } catch (BaseException e) {
            LOGGER.error("LspInfoController.afterAuthLspLine ERROR... ", e);
            result = new RestfulResponse<>(CommonEnum.ERROR.getCode(), e.getMessage(), null);
        } catch (Exception e) {
            LOGGER.error("LspInfoController.afterAuthLspLine ERROR... ", e);
            result = new RestfulResponse<>(CommonEnum.ERROR.getCode(), CommonEnum.ERROR.getText(), null);
        }

        return result;
    }

    /**
     * 承运商认证
     *
     * @param commonBO
     * @return
     */
    @PostMapping(value = "/lspAuth")
    @ApiOperation(value = "承运商认证", notes = "承运商认证", produces = MediaType.APPLICATION_JSON_VALUE, response =
            RestfulResponse.class)
    public RestfulResponse lspAuth(@RequestBody CommonVo commonBO) {
        LOGGER.info("LspInfoController.lspAuth（承运商认证） params : {} ");
        RestfulResponse result = new RestfulResponse<>(CommonEnum.SUCCESS.getCode(), CommonEnum.SUCCESS.getText(),
                null);
        try {
            List<String> msg = lspInfoService.lspAuth(commonBO.getLspIds());
            if (!CollectionUtils.isEmpty(msg)) {
                result = new RestfulResponse<>(CommonEnum.ERRORLIST.getCode(), "部分认证失败", msg);
            }
        } catch (BaseException e) {
            LOGGER.error("LspInfoController.lspAuth ERROR... ", e);
            result = new RestfulResponse<>(CommonEnum.ERROR.getCode(), e.getMessage(), null);
        } catch (Exception e) {
            LOGGER.error("LspInfoController.lspAuth ERROR... ", e);
            result = new RestfulResponse<>(CommonEnum.ERROR.getCode(), CommonEnum.ERROR.getText(), null);
        }
        return result;
    }

    /**
     * 取消认证
     *
     * @param commonBO
     * @return
     */
    @PostMapping(value = "/cancelAuth")
    @ApiOperation(value = "承运商取消认证", notes = "承运商取消认证", produces = MediaType.APPLICATION_JSON_VALUE, response =
            RestfulResponse.class)
    public RestfulResponse cancelAuth(@RequestBody CommonVo commonBO) {
        LOGGER.info("LspInfoController.cancelAuth（承运商取消认证） params : {} ", commonBO.toString());

        RestfulResponse result = new RestfulResponse<>(CommonEnum.SUCCESS.getCode(), CommonEnum.SUCCESS.getText(),
                null);
        try {
            lspInfoService.cancelAuth(commonBO.getLspIds());
        } catch (BaseException e) {
            LOGGER.error("LspInfoController.cancelAuth ERROR... ", e);
            result = new RestfulResponse<>(CommonEnum.ERROR.getCode(), e.getMessage(), null);
        } catch (Exception e) {
            LOGGER.error("LspInfoController.cancelAuth ERROR... ", e);
            result = new RestfulResponse<>(CommonEnum.ERROR.getCode(), CommonEnum.ERROR.getText(), null);
        }

        return result;
    }

    @PostMapping(value = "/discontinuatLsp")
    @ApiOperation(value = "停用承运商", notes = "停用承运商", produces = MediaType.APPLICATION_JSON_VALUE, response =
            RestfulResponse.class)
    public RestfulResponse discontinuatLsp(@RequestBody CommonVo commonBO) {
        LOGGER.info("LspInfoController.discontinuatLsp（停用承运商） params : {} ", commonBO.toString());
        RestfulResponse result = new RestfulResponse<>(CommonEnum.SUCCESS.getCode(), CommonEnum.SUCCESS.getText(),
                null);
        try {
            lspInfoService.discontinuatLsps(commonBO.getLspIds());
        } catch (BaseException e) {
            LOGGER.error("LspInfoController.discontinuatLsp ERROR... ", e);
            result = new RestfulResponse<>(CommonEnum.ERROR.getCode(), e.getMessage(), null);
        } catch (Exception e) {
            LOGGER.error("LspInfoController.discontinuatLsp ERROR... ", e);
            result = new RestfulResponse<>(CommonEnum.ERROR.getCode(), CommonEnum.ERROR.getText(), null);
        }
        return result;
    }

    @PostMapping(value = "/enableLsp")
    @ApiOperation(value = "启用承运商", notes = "启用承运商", produces = MediaType.APPLICATION_JSON_VALUE, response =
            RestfulResponse.class)
    public RestfulResponse enableLsp(@RequestBody CommonVo commonBO) {
        LOGGER.info("LspInfoController.enableLsp（启用承运商） params : {} ", commonBO.toString());

        RestfulResponse result = new RestfulResponse<>(CommonEnum.SUCCESS.getCode(), CommonEnum.SUCCESS.getText(),
                null);
        try {
            lspInfoService.enableLsps(commonBO.getLspIds());
        } catch (BaseException e) {
            LOGGER.error("LspInfoController.enableLsp ERROR... ", e);
            result = new RestfulResponse<>(CommonEnum.ERROR.getCode(), e.getMessage(), null);
        } catch (Exception e) {
            LOGGER.error("LspInfoController.enableLsp ERROR... ", e);
            result = new RestfulResponse<>(CommonEnum.ERROR.getCode(), CommonEnum.ERROR.getText(), null);
        }

        return result;
    }
//
//    @PostMapping(value = "/addLspInfo")
//    @ApiOperation(value = "添加承运商基础信息", notes = "添加承运商基础信息", produces = MediaType.APPLICATION_JSON_VALUE, response =
//            RestfulResponse.class)
//    public RestfulResponse<LspInfo> addLspInfo(@RequestBody ModifyLspInfoBO modifyLspInfoBO,
//                                               @RequestHeader("Authorization") String authorization) {
//        LOGGER.info("LspInfoController.addLspInfo（添加承运商基础信息） params : {} ", modifyLspInfoBO.toString());
//        RestfulResponse<LspInfo> result = new RestfulResponse(CommonEnum.SUCCESS.getCode(), CommonEnum.SUCCESS.getText(), null);
//        try {
//            lspInfoService.addLspInfo(modifyLspInfoBO, authorization);
//            EntityWrapper<LspInfo> ew = new EntityWrapper<>();
//            ew.eq("name", modifyLspInfoBO.getName().trim())
//                    .or()
//                    .eq("name_abbr", modifyLspInfoBO.getNameAbbr().trim());
//            result.setData(lspInfoService.selectOne(ew));
//        } catch (BaseException e) {
//            LOGGER.error("LspInfoController.addLspInfo ERROR... ", e);
//            result = new RestfulResponse<>(CommonEnum.ERROR.getCode(), e.getMessage(), null);
//        } catch (Exception e) {
//            LOGGER.error("LspInfoController.addLspInfo ERROR... ", e);
//            result = new RestfulResponse<>(CommonEnum.ERROR.getCode(), CommonEnum.ERROR.getText(), null);
//        }
//
//        return result;
//    }
//
//    @PostMapping(value = "/updateLspLicense")
//    @ApiOperation(value = "修改指定的承运商附件信息", notes = "修改指定的承运商附件信息", produces = MediaType.APPLICATION_JSON_VALUE, response =
//            RestfulResponse.class)
//    public RestfulResponse updateLspLicense(@RequestBody ModifyLspInfoBO modifyLspInfoBO) {
//        LOGGER.info("LspInfoController.updateLspLicense（修改承运商附件信息） params : {} ", modifyLspInfoBO.toString());
//        RestfulResponse result = new RestfulResponse(CommonEnum.SUCCESS.getCode(), CommonEnum.SUCCESS.getText(), null);
//        try {
//            lspInfoService.updateLicense(modifyLspInfoBO);
//        } catch (BaseException e) {
//            LOGGER.error("LspInfoController.updateLspLicense ERROR... ", e);
//            result = new RestfulResponse<>(CommonEnum.ERROR.getCode(), e.getMessage(), null);
//        } catch (Exception e) {
//            LOGGER.error("LspInfoController.updateLspLicense ERROR... ", e);
//            result = new RestfulResponse<>(CommonEnum.ERROR.getCode(), CommonEnum.ERROR.getText(), null);
//        }
//        return result;
//    }
//
//    @PostMapping(value = "/deleteLspLicense")
//    @ApiOperation(value = "删除指定的承运商附件信息", notes = "删除指定的承运商附件信息", produces = MediaType.APPLICATION_JSON_VALUE, response =
//            RestfulResponse.class)
//    public RestfulResponse deleteLspLicense(@RequestBody ModifyLspLicenseBO modifyLspLicenseBO) {
//        LOGGER.info("LspInfoController.deleteLspLicense（删除指定的承运商附件信息） params : {} ", modifyLspLicenseBO.toString());
//        RestfulResponse result = new RestfulResponse(CommonEnum.SUCCESS.getCode(), CommonEnum.SUCCESS.getText(), null);
//        try {
//            lspInfoService.deleteLicense(modifyLspLicenseBO);
//        } catch (BaseException e) {
//            LOGGER.error("LspInfoController.deleteLspLicense ERROR... ", e);
//            result = new RestfulResponse<>(CommonEnum.ERROR.getCode(), e.getMessage(), null);
//        } catch (Exception e) {
//            LOGGER.error("LspInfoController.deleteLspLicense ERROR... ", e);
//            result = new RestfulResponse<>(CommonEnum.ERROR.getCode(), CommonEnum.ERROR.getText(), null);
//        }
//        return result;
//    }

    @GetMapping(value = "/findModifyInfo")
    @ApiOperation(value = "查找编辑承运商信息", notes = "查找编辑承运商信息", produces = MediaType.APPLICATION_JSON_VALUE, response =
            RestfulResponse.class)
    public RestfulResponse<ModifyLspInfoBO> findModifyInfo(Long id) {
        LOGGER.info("LspInfoController.findModifyInfo（查找编辑承运商信息） params : {} ", id);

        RestfulResponse<ModifyLspInfoBO> result = new RestfulResponse<>(CommonEnum.SUCCESS.getCode(), CommonEnum
                .SUCCESS.getText(), null);

        try {
            ModifyLspInfoBO modifyLspInfoBO = lspInfoService.findModifyInfo(id);
            result.setData(modifyLspInfoBO);
        } catch (BaseException e) {
            LOGGER.error("LspInfoController.findModifyInfo ERROR... ", e);
            result = new RestfulResponse<>(CommonEnum.ERROR.getCode(), e.getMessage(), null);
        } catch (Exception e) {
            LOGGER.error("LspInfoController.findModifyInfo ERROR... ", e);
            result = new RestfulResponse<>(CommonEnum.ERROR.getCode(), CommonEnum.ERROR.getText(), null);
        }

        return result;
    }

    @GetMapping(value = "/findByCode")
    @ApiOperation(value = "根据编码查询承运商信息", notes = "根据编码查询承运商信息", produces = MediaType.APPLICATION_JSON_VALUE, response
            = RestfulResponse.class)
    public RestfulResponse<ModifyLspInfoBO> findByCode(String code) {
        LOGGER.info("LspInfoController.findByCode（根据编码查询承运商信息） params : {} ", code);
        RestfulResponse<ModifyLspInfoBO> result = new RestfulResponse<>(CommonEnum.SUCCESS.getCode(), CommonEnum
                .SUCCESS.getText(), null);
        try {
            result.setData(lspInfoService.findByCode(code));
        } catch (BaseException e) {
            LOGGER.error("LspInfoController.findByCode ERROR... ", e);
            result = new RestfulResponse<>(CommonEnum.ERROR.getCode(), e.getMessage(), null);
        } catch (Exception e) {
            LOGGER.error("LspInfoController.findByCode ERROR... ", e);
            result = new RestfulResponse<>(CommonEnum.ERROR.getCode(), CommonEnum.ERROR.getText(), null);
        }
        return result;
    }

//    @PostMapping(value = "/modifyLspInfo")
//    @ApiOperation(value = "编辑承运商基础信息", notes = "编辑承运商基础信息", produces = MediaType.APPLICATION_JSON_VALUE, response =
//            RestfulResponse.class)
//    public RestfulResponse modifyLspInfo(@RequestBody ModifyLspInfoBO modifyLspInfoBO,
//                                         @RequestHeader("Authorization") String authorization) {
//        LOGGER.info("LspInfoController.modifyLspInfo（编辑承运商基础信息） params : {} ", modifyLspInfoBO.toString());
//
//        RestfulResponse result = new RestfulResponse<>(CommonEnum.SUCCESS.getCode(), CommonEnum.SUCCESS.getText(),
//                null);
//        try {
//            lspInfoService.modifyLspInfo(modifyLspInfoBO, authorization);
//        } catch (BaseException e) {
//            LOGGER.error("LspInfoController.modifyLspInfo ERROR... ", e);
//            result = new RestfulResponse<>(CommonEnum.ERROR.getCode(), e.getMessage(), null);
//        } catch (Exception e) {
//            LOGGER.error("LspInfoController.modifyLspInfo ERROR... ", e);
//            result = new RestfulResponse<>(CommonEnum.ERROR.getCode(), CommonEnum.ERROR.getText(), null);
//        }
//        return result;
//    }

    @GetMapping(value = "/vagueSelectLsp")
    @ApiOperation(value = "模糊查询已认证的承运商信息", notes = "模糊查询已认证的承运商信息", produces = MediaType.APPLICATION_JSON_VALUE,
            response = RestfulResponse.class)
    public RestfulResponse<List<LspInfo>> vagueSelectLsp(String name) {
        LOGGER.info("LspInfoController.vagueSelectLsp（模糊查询已认证的承运商信息） params : {} ", name);
        RestfulResponse result = new RestfulResponse<>(CommonEnum.SUCCESS.getCode(), CommonEnum.SUCCESS.getText(),
                null);
        try {
            result.setData(lspInfoService.vagueSelectLsp(name));
        } catch (BaseException e) {
            LOGGER.error("LspInfoController.vagueSelectLsp ERROR... ", e);
            result = new RestfulResponse<>(CommonEnum.ERROR.getCode(), e.getMessage(), null);
        } catch (Exception e) {
            LOGGER.error("LspInfoController.vagueSelectLsp ERROR... ", e);
            result = new RestfulResponse<>(CommonEnum.ERROR.getCode(), CommonEnum.ERROR.getText(), null);
        }

        return result;
    }

    @PostMapping(value = "/deleteLsp")
    @ApiOperation(value = "删除承运商", notes = "删除承运商", produces = MediaType.APPLICATION_JSON_VALUE, response =
            RestfulResponse.class)
    public RestfulResponse<List<String>> deleteLsp(@RequestBody CommonVo commonBO,
                                                   @RequestHeader("Authorization") String token) {
        LOGGER.info("CarrierController.cancelAuthCarrier（删除承运商） params : {} ", commonBO.toString());
        RestfulResponse<List<String>> result = new RestfulResponse<>(CommonEnum.SUCCESS.getCode(), CommonEnum.SUCCESS.getText(),
                null);
        try {
            List<String> msgs = lspInfoService.deleteByIds(commonBO.getLspIds(), token);
            if (!CollectionUtils.isEmpty(msgs)) {
                result = new RestfulResponse<>(CommonEnum.ERRORLIST.getCode(), "部分承运商删除失败", msgs);
            }
        } catch (BaseException e) {
            LOGGER.error("CarrierController.cancelAuthCarrier ERROR... ", e);
            result = new RestfulResponse<>(CommonEnum.ERROR.getCode(), e.getMessage(), null);
        } catch (Exception e) {
            LOGGER.error("CarrierController.cancelAuthCarrier ERROR... ", e);
            result = new RestfulResponse<>(CommonEnum.ERROR.getCode(), CommonEnum.ERROR.getText(), null);
        }
        return result;
    }

    @PostMapping(value = "/registLsp")
    @ApiOperation(value = "根据uaa的数据添加承运商信息", notes = "根据uaa的数据添加承运商信息", produces = MediaType.APPLICATION_JSON_VALUE, response =
            RestfulResponse.class)
    public RestfulResponse registLsp(@RequestBody TenantInfoVO tenantVO) {
        LOGGER.info("CarrierController.registLsp（根据名称获取公司的企业信息） params : {} ", tenantVO);
        RestfulResponse result = new RestfulResponse<>(CommonEnum.SUCCESS.getCode(), CommonEnum.SUCCESS.getText(),
                null);
        try {
            lspInfoService.registLsp(tenantVO);
        } catch (BaseException e) {
            result.setCode(-1);
            result.setMessage("创建公司失败！");
        }
        return result;
    }

    @GetMapping(value = "/listLspInfo")
    @ApiOperation(value = "根据名称获取公司", notes = "根据名称获取公司", produces = MediaType.APPLICATION_JSON_VALUE, response =
            RestfulResponse.class)
    public RestfulResponse<List<LspInfo>> listLspInfo(String corpName) {
        RestfulResponse result = new RestfulResponse<>(CommonEnum.SUCCESS.getCode(), CommonEnum.SUCCESS.getText(), null);
        if (StringUtils.isEmpty(corpName))
            result.setData(lspInfoService.selectList(null));
        EntityWrapper<LspInfo> ew = new EntityWrapper<>();
        ((EntityWrapper) ew).like("name", corpName);
        result.setData(lspInfoService.selectList(ew));
        return result;
    }

    /**
     * 根据企业名称获取企业信息
     *
     * @param corpName
     * @return
     */
    @GetMapping(value = "/getLspEnterprise")
    @ApiOperation(value = "根据名称获取公司的企业信息", notes = "根据名称获取公司的企业信息", produces = MediaType.APPLICATION_JSON_VALUE, response = RestfulResponse.class)
    public RestfulResponse<String> getLspEnterprise(String corpName) {
        LOGGER.info("CarrierController.getLspEnterprise（根据名称获取公司的企业信息） params : {} ", corpName);
        RestfulResponse result = new RestfulResponse<>(CommonEnum.SUCCESS.getCode(), CommonEnum.SUCCESS.getText(),
                null);
        try {
        } catch (BaseException e) {
            LOGGER.error("CarrierController.getLspEnterprise ERROR... ", e);
            result = new RestfulResponse<>(CommonEnum.ERROR.getCode(), e.getMessage(), null);
        } catch (Exception e) {
            LOGGER.error("CarrierController.getLspEnterprise ERROR... ", e);
            result = new RestfulResponse<>(CommonEnum.ERROR.getCode(), CommonEnum.ERROR.getText(), null);
        }
        return result;
    }


    /**
     * 创建承运商
     *
     * @param lspInfoParam 承运商信息参数
     * @return 创建后的承运商信息列
     */
    @PostMapping(value = "/insertOrUpdateLsp")
    @ApiOperation(value = "创建或更新承运商", notes = "创建或更新承运商", produces = MediaType.APPLICATION_JSON_VALUE, response = RestfulResponse.class)
    public RestfulResponse<LspBasicVO> insertOrUpdateLsp(@RequestBody LspBasicVO lspInfoParam, @RequestHeader("Authorization") String authorization) {
        LOGGER.info("CarrierController.insertOrUpdateLsp（创建或更新承运商） params : {} ", lspInfoParam.toString());
        RestfulResponse<LspBasicVO> result = new RestfulResponse<>(CommonEnum.SUCCESS.getCode(), CommonEnum.SUCCESS.getText(),
                null);
        try {
            LspBasicVO lspInfo = lspInfoService.updateLspInfo(lspInfoParam, authorization);
            result.setData(lspInfo);
        } catch (BaseException e) {
            LOGGER.error("CarrierController.insertOrUpdateLsp ERROR... ", e);
            result = new RestfulResponse<>(CommonEnum.ERROR.getCode(), e.getMessage(), null);
        } catch (Exception e) {
            LOGGER.error("CarrierController.insertOrUpdateLsp ERROR... ", e);
            result = new RestfulResponse<>(CommonEnum.ERROR.getCode(), CommonEnum.ERROR.getText(), null);
        }
        return result;
    }

    /**
     * 根据id获取承运商信息
     *
     * @param lspId
     * @return
     */
    @GetMapping(value = "/getLsp")
    @ApiOperation(value = "获取承运商", notes = "获取承运商", produces = MediaType.APPLICATION_JSON_VALUE, response = RestfulResponse.class)
    public RestfulResponse<LspBasicVO> getLsp(Long lspId) {
        LOGGER.info("CarrierController.getLsp（获取承运商信息） params : {} ", lspId);
        RestfulResponse<LspBasicVO> result = new RestfulResponse<>(CommonEnum.SUCCESS.getCode(), CommonEnum.SUCCESS.getText(),
                null);
        try {
            result.setData(lspInfoService.getLspBasic(lspId));
        } catch (BaseException e) {
            LOGGER.error("CarrierController.getLsp ERROR... ", e);
            result = new RestfulResponse<>(CommonEnum.ERROR.getCode(), e.getMessage(), null);
        } catch (Exception e) {
            LOGGER.error("CarrierController.getLsp ERROR... ", e);
            result = new RestfulResponse<>(CommonEnum.ERROR.getCode(), CommonEnum.ERROR.getText(), null);
        }
        return result;
    }

    /**
     * 根据id获取承运商信息
     *
     * @param lspId
     * @return
     */
    @GetMapping(value = "/getLspByIdNoTenant")
    @ApiOperation(value = "获取承运商", notes = "获取承运商", produces = MediaType.APPLICATION_JSON_VALUE, response = RestfulResponse.class)
    public RestfulResponse<LspInfo> getLspNoTenant(Long lspId) {
        LOGGER.info("CarrierController.getLsp（获取承运商信息） params : {} ", lspId);
        RestfulResponse<LspInfo> result = new RestfulResponse<>(CommonEnum.SUCCESS.getCode(), CommonEnum.SUCCESS.getText(),
                null);
        try {
            result.setData(lspInfoService.getLspByLspIdNoTenant(lspId));
        } catch (BaseException e) {
            LOGGER.error("CarrierController.getLsp ERROR... ", e);
            result = new RestfulResponse<>(CommonEnum.ERROR.getCode(), e.getMessage(), null);
        } catch (Exception e) {
            LOGGER.error("CarrierController.getLsp ERROR... ", e);
            result = new RestfulResponse<>(CommonEnum.ERROR.getCode(), CommonEnum.ERROR.getText(), null);
        }
        return result;
    }

    /**
     * 根据id获取油卡信息
     *
     * @param lspId
     * @return
     */
    @GetMapping(value = "/getCard")
    @ApiOperation(value = "获取油卡", notes = "获取油卡", produces = MediaType.APPLICATION_JSON_VALUE, response = RestfulResponse.class)
    public RestfulResponse<List<LspCard>> getCard(Long lspId) {
        LOGGER.info("CarrierController.getCard（获取油卡） params : {} ", lspId);
        RestfulResponse<List<LspCard>> result = new RestfulResponse<>(CommonEnum.SUCCESS.getCode(), CommonEnum.SUCCESS.getText(),
                null);
        try {
            EntityWrapper lspCardew = new EntityWrapper<>();
            lspCardew.eq("lsp_id", lspId);
            List<LspCard> l = lspCardService.selectList(lspCardew);
            result.setData(l);
        } catch (BaseException e) {
            LOGGER.error("CarrierController.getCard ERROR... ", e);
            result = new RestfulResponse<>(CommonEnum.ERROR.getCode(), e.getMessage(), null);
        } catch (Exception e) {
            LOGGER.error("CarrierController.getCard ERROR... ", e);
            result = new RestfulResponse<>(CommonEnum.ERROR.getCode(), CommonEnum.ERROR.getText(), null);
        }
        return result;
    }

    /**
     * 根据id获取银行卡信息
     *
     * @param lspId
     * @return
     */
    @GetMapping(value = "/getBank")
    @ApiOperation(value = "获取银行卡", notes = "获取银行卡", produces = MediaType.APPLICATION_JSON_VALUE, response = RestfulResponse.class)
    public RestfulResponse<List<LspBankAccount>> getBank(Long lspId) {
        LOGGER.info("CarrierController.getBank（获取油卡） params : {} ", lspId);
        RestfulResponse<List<LspBankAccount>> result = new RestfulResponse<>(CommonEnum.SUCCESS.getCode(), CommonEnum.SUCCESS.getText(),
                null);
        try {
            EntityWrapper lspBankew = new EntityWrapper<>();
            lspBankew.eq("lsp_id", lspId);
            result.setData(lspBankAccountService.selectList(lspBankew));
        } catch (BaseException e) {
            LOGGER.error("CarrierController.getBank ERROR... ", e);
            result = new RestfulResponse<>(CommonEnum.ERROR.getCode(), e.getMessage(), null);
        } catch (Exception e) {
            LOGGER.error("CarrierController.getBank ERROR... ", e);
            result = new RestfulResponse<>(CommonEnum.ERROR.getCode(), CommonEnum.ERROR.getText(), null);
        }
        return result;
    }

    @PostMapping(value = "/updateBank")
    @ApiOperation(value = "更新银行卡", notes = "更新银行卡", produces = MediaType.APPLICATION_JSON_VALUE, response = RestfulResponse.class)
    public RestfulResponse<String> updateBank(@RequestBody LspBanksVO lspBankAccounts) {
        LOGGER.info("CarrierController.updateBank（更新银行卡） params : {} ", lspBankAccounts);
        RestfulResponse<String> result = new RestfulResponse<>(CommonEnum.SUCCESS.getCode(), CommonEnum.SUCCESS.getText(),
                null);
        try {
            for (LspBankAccount lspBankAccount :
                    lspBankAccounts.getLspBankAccounts()) {
                if (Objects.nonNull(lspBankAccount.getId())) {
                    lspBankAccountService.updateById(lspBankAccount);
                } else {
                    JwtAccountVO jwtAccount = AccountUtil.getAccountInfoFromSecurityContext();
                    lspBankAccount.setLspId(lspBankAccounts.getLspId());
                    if (Objects.nonNull(jwtAccount)) {
                        lspBankAccount.setCreator(jwtAccount.getUsername());
                    }
                    lspBankAccount.setLspId(lspBankAccounts.getLspId());
                    lspBankAccountService.insert(lspBankAccount);
                }
            }
        } catch (BaseException e) {
            LOGGER.error("CarrierController.updateBank ERROR... ", e);
            result = new RestfulResponse<>(CommonEnum.ERROR.getCode(), e.getMessage(), null);
        } catch (Exception e) {
            LOGGER.error("CarrierController.updateBank ERROR... ", e);
            result = new RestfulResponse<>(CommonEnum.ERROR.getCode(), CommonEnum.ERROR.getText(), null);
        }
        return result;
    }

    @PostMapping(value = "/updateCard")
    @ApiOperation(value = "更新油卡", notes = "更新油卡", produces = MediaType.APPLICATION_JSON_VALUE, response = RestfulResponse.class)
    public RestfulResponse<String> updateCard(@RequestBody LspCardsVO lspCardsVO) {
        LOGGER.info("CarrierController.updateCard（更新油卡） params : {} ", lspCardsVO);
        RestfulResponse<String> result = new RestfulResponse<>(CommonEnum.SUCCESS.getCode(), CommonEnum.SUCCESS.getText(),
                null);
        try {
            for (LspCard lspCard :
                    lspCardsVO.getLspCards()) {
                if (Objects.nonNull(lspCard.getId())) {
                    lspCardService.updateById(lspCard);
                } else {
                    JwtAccountVO jwtAccount = AccountUtil.getAccountInfoFromSecurityContext();
                    if (Objects.nonNull(jwtAccount)) {
                        lspCard.setCreator(jwtAccount.getUsername());
                    }
                    lspCard.setLspId(lspCardsVO.getLspId());
                    lspCardService.insert(lspCard);
                }
            }
        } catch (BaseException e) {
            LOGGER.error("CarrierController.updateCard ERROR... ", e);
            result = new RestfulResponse<>(CommonEnum.ERROR.getCode(), e.getMessage(), null);
        } catch (Exception e) {
            LOGGER.error("CarrierController.updateCard ERROR... ", e);
            result = new RestfulResponse<>(CommonEnum.ERROR.getCode(), CommonEnum.ERROR.getText(), null);
        }
        return result;
    }

    @PostMapping(value = "/openLsp")
    @ApiOperation(value = "开通承运商", notes = "开通承运商", produces = MediaType.APPLICATION_JSON_VALUE, response = RestfulResponse.class)
    @ApiResponses({@ApiResponse(code = 0, message = "success", response = String.class), @ApiResponse(code = -1, message = "操作失败", response = Object.class)})
    public RestfulResponse<String> openLsp(@RequestBody LspAccountVO lspAccountVO, @RequestHeader("Authorization") String authorization) {
        LOGGER.info("CarrierController.openLsp（开通承运商） params : {}", lspAccountVO);
        RestfulResponse<String> result = new RestfulResponse<>(CommonEnum.SUCCESS.getCode(), CommonEnum.SUCCESS.getText(),
                null);
        try {
            lspInfoService.unlockAccount(lspAccountVO.getTenantId(), authorization);
        } catch (BaseException e) {
            LOGGER.error("CarrierController.openLsp ERROR... ", e);
            result = new RestfulResponse<>(CommonEnum.ERROR.getCode(), e.getMessage(), null);
        } catch (Exception e) {
            LOGGER.error("CarrierController.openLsp ERROR... ", e);
            result = new RestfulResponse<>(CommonEnum.ERROR.getCode(), CommonEnum.ERROR.getText(), null);
        }
        return result;
    }

    @PostMapping(value = "/addLspAndOpenLsp")
    @ApiOperation(value = "添加承运商后开通承运商", notes = "添加承运商后开通承运商", produces = MediaType.APPLICATION_JSON_VALUE, response = RestfulResponse.class)
    @ApiResponses({@ApiResponse(code = 0, message = "success", response = String.class), @ApiResponse(code = -1, message = "操作失败", response = Object.class)})
    public RestfulResponse<String> addLspAndOpenLsp(@RequestBody LspAccountVO lspAccountVO, @RequestHeader("Authorization") String authorization) {
        LOGGER.info("CarrierController.openLsp（添加承运商后开通承运商） params : {}", lspAccountVO);
        RestfulResponse<String> result = new RestfulResponse<>(CommonEnum.SUCCESS.getCode(), CommonEnum.SUCCESS.getText(),
                null);
        try {
            lspInfoService.lspSendMessage(lspInfoService.selectById(lspAccountVO.getId()), lspAccountVO.getTaxpayerId(), lspAccountVO.getIsOpenUp(), authorization);
        } catch (BaseException e) {
            LOGGER.error("CarrierController.openLsp ERROR... ", e);
            result = new RestfulResponse<>(CommonEnum.ERROR.getCode(), e.getMessage(), null);
        } catch (Exception e) {
            LOGGER.error("CarrierController.openLsp ERROR... ", e);
            result = new RestfulResponse<>(CommonEnum.ERROR.getCode(), CommonEnum.ERROR.getText(), null);
        }
        return result;
    }

    /**
     * 承运商列表
     *
     * @param page
     * @return
     */
    @PostMapping(value = "/openAccountList")
    @ApiOperation(value = "获取开通账号列表", notes = "获取开通账号列表", produces = MediaType.APPLICATION_JSON_VALUE, response
            = RestfulResponse.class)
    @ApiResponses({@ApiResponse(code = 0, message = "success", response = LspAccountVO.class), @ApiResponse(code = -1, message = "操作失败", response = Object.class)})
    public RestfulResponse<Page<LspAccountVO>> openAccountList(@RequestBody Page<LspAccountVO> page, @RequestHeader("Authorization") String authorization) {
        LOGGER.info("LspInfoController.openAccountList（获取开通账号列表） params : {} ", page);
        RestfulResponse<Page<LspAccountVO>> result = new RestfulResponse<>(CommonEnum.SUCCESS.getCode(), CommonEnum
                .SUCCESS.getText(), null);
        try {
            Page<LspAccountVO> pageVo = lspInfoService.openAccountList(page, authorization);
            result.setData(pageVo);
        } catch (BaseException e) {
            LOGGER.error("LspInfoController.openAccountList ERROR... ", e);
            result = new RestfulResponse<>(CommonEnum.ERROR.getCode(), e.getMessage(), null);
        } catch (Exception e) {
            LOGGER.error("LspInfoController.openAccountList ERROR... ", e);
            result = new RestfulResponse<>(CommonEnum.ERROR.getCode(), e.getMessage(), null);
        }
        return result;
    }

    @PostMapping(value = "/updateDeleteStatus")
    @ApiOperation(value = "恢复承运商删除状态", notes = "恢复承运商删除状态", produces = MediaType.APPLICATION_JSON_VALUE, response
            = RestfulResponse.class)
    @ApiResponses({@ApiResponse(code = 0, message = "success"), @ApiResponse(code = -1, message = "操作失败", response = Object.class)})
    public RestfulResponse<List<String>> updateDeleteStatus(@RequestBody List<Long> ids,
                                                            @RequestHeader("Authorization") String token) {
        LOGGER.info("LspInfoController.updateDeleteStatus（恢复承运商删除状态） params : {} ", ids);
        RestfulResponse<List<String>> result = new RestfulResponse<>(CommonEnum.SUCCESS.getCode(), CommonEnum
                .SUCCESS.getText(), null);
        try {
            List<String> msgs = lspInfoService.updateDeleteStatus(ids, token);
            if (!CollectionUtils.isEmpty(msgs)) {
                result = new RestfulResponse<>(CommonEnum.ERRORLIST.getCode(), "部分承运商删除失败", msgs);
            }
        } catch (BaseException e) {
            LOGGER.error("LspInfoController.updateDeleteStatus ERROR... ", e);
            result = new RestfulResponse<>(CommonEnum.ERROR.getCode(), e.getMessage(), null);
        } catch (Exception e) {
            LOGGER.error("LspInfoController.updateDeleteStatus ERROR... ", e);
            result = new RestfulResponse<>(CommonEnum.ERROR.getCode(), e.getMessage(), null);
        }
        return result;
    }

    /**
     * 根据id获取承运商信息
     *
     * @return
     */
    @GetMapping(value = "/getLspByLoginAccount")
    @ApiOperation(value = "根据登录用户获取公司", notes = "根据登录用户获取公司", produces = MediaType.APPLICATION_JSON_VALUE, response = RestfulResponse.class)
    public RestfulResponse<LspBasicVO> getLspByLoginAccount() {
        LOGGER.info("CarrierController.getLspByLoginAccount（根据登录用户获取公司） ");
        RestfulResponse<LspBasicVO> result = new RestfulResponse<>(CommonEnum.SUCCESS.getCode(), CommonEnum.SUCCESS.getText(),
                null);
        try {
            result.setData(lspInfoService.getLspByLoginAccount());
        } catch (BaseException e) {
            LOGGER.error("CarrierController.getLspByLoginAccount ERROR... ", e);
            result = new RestfulResponse<>(CommonEnum.ERROR.getCode(), e.getMessage(), null);
        } catch (Exception e) {
            LOGGER.error("CarrierController.getLspByLoginAccount ERROR... ", e);
            result = new RestfulResponse<>(CommonEnum.ERROR.getCode(), CommonEnum.ERROR.getText(), null);
        }
        return result;
    }

    /**
     * 查询四大家名称
     */
    @GetMapping(value = "/listFourLspInfo")
    @ApiOperation(value = "查询四大家名称", notes = "查询四大家名称", produces = MediaType.APPLICATION_JSON_VALUE, response =
            RestfulResponse.class)
    public RestfulResponse<List<LspInfo>> listFourLspInfo() {
        RestfulResponse result = new RestfulResponse<>(CommonEnum.SUCCESS.getCode(), CommonEnum.SUCCESS.getText(), null);
        try {
            EntityWrapper<LspInfo> ew = new EntityWrapper<>();
            List<String> nameList = Lists.newArrayList();
            nameList.add("江西路易通达运输有限公司");
            nameList.add("景德镇久顺途运输有限公司");
            nameList.add("江西佳迅运输有限公司");
            nameList.add("鹰潭运捷运输有限公司");
            ew.in("name", nameList);
            result.setData(lspInfoService.selectList(ew));
        } catch (BaseException e) {
            LOGGER.error("CarrierController.listFourLspInfo ERROR {}", e);
            result = new RestfulResponse<>(CommonEnum.ERROR.getCode(), e.getMessage(), null);
        } catch (Exception e) {
            result = new RestfulResponse<>(CommonEnum.ERROR.getCode(), CommonEnum.ERROR.getText(), null);
        }
        return result;
    }

    /**
     * 根据承运商Id批量获取承运商信息
     *
     * @param lspIds
     * @return
     */
    @PostMapping(value = "/getLspName")
    @ApiOperation(value = "获取承运商", notes = "获取承运商", produces = MediaType.APPLICATION_JSON_VALUE, response = RestfulResponse.class)
    public RestfulResponse<List<LspInfo>> getLspName(@RequestBody List<Long> lspIds) {
        LOGGER.info("CarrierController.getLspName（获取承运商信息） params : {} ", lspIds);
        RestfulResponse<List<LspInfo>> result = new RestfulResponse<>(CommonEnum.SUCCESS.getCode(), CommonEnum.SUCCESS.getText(),
                null);
        try {
            List<LspInfo> lspInfo = lspInfoService.getLspName(lspIds);
            result.setData(lspInfo);
        } catch (BaseException e) {
            LOGGER.error("CarrierController.getLspName ERROR {}", e);
            result = new RestfulResponse<>(CommonEnum.ERROR.getCode(), e.getMessage(), null);
        } catch (Exception e) {
            LOGGER.error("CarrierController.getLspName ERROR {}", e);
            result = new RestfulResponse<>(CommonEnum.ERROR.getCode(), CommonEnum.ERROR.getText(), null);
        }
        return result;
    }

    @GetMapping(value = "/queryLspInfoByTenantId")
    @ApiOperation(value = "/queryLspInfoByTenantId", notes = "根据租户id查询承运商", response = RestfulResponse.class)
    public RestfulResponse<LspInfo> queryOrderItem(Long tenantId) {
        LOGGER.info("controller:/Lsp/queryLspInfoByTenantId data: {}", tenantId);
        RestfulResponse result = new RestfulResponse(0, "成功", null);
        try {
            LspInfo lspInfo = lspInfoService.queryLspInfoByTenantId(tenantId);
            result.setData(lspInfo);
        } catch (Exception e) {
            result.setCode(-1);
            result.setMessage(e.getMessage());
        }
        return result;
    }

    @GetMapping(value = "/lspToOtm/{id}")
    @ApiOperation(value = "根据承运商id推送承运商到otm", notes = "根据承运商id推送承运商到otm", response = RestfulResponse.class)
    public RestfulResponse<LspInfo> lspToOtm(@PathVariable Long id) {
        LOGGER.info("controller:/Lsp/lspToOtm data: {}", id);
        RestfulResponse result = new RestfulResponse(0, "成功", null);
        try {
            result.setData(lspInfoService.lspToOtm(id));
        } catch (BaseException e) {
            LOGGER.error("CarrierController.lspToOtm ERROR {}", e);
            result = new RestfulResponse<>(CommonEnum.ERROR.getCode(), e.getMessage(), null);
        } catch (Exception e) {
            LOGGER.error("CarrierController.lspToOtm ERROR {}", e);
            result = new RestfulResponse<>(CommonEnum.ERROR.getCode(), CommonEnum.ERROR.getText(), null);
        }
        return result;
    }

    /**
     * 根据承运商Id批量获取承运商信息
     *
     * @return
     */
    @PostMapping(value = "/getLspInfoAll")
    @ApiOperation(value = "批量获取承运商信息", notes = "批量获取承运商信息", produces = MediaType.APPLICATION_JSON_VALUE, response = RestfulResponse.class)
    public RestfulResponse<List<LspInfo>> getLspInfoAll(@RequestBody List<LspInfo> lspInfos) {
        LOGGER.info("CarrierController.getLspInfoAll（获取承运商信息） params : {} ", lspInfos);
        RestfulResponse<List<LspInfo>> result = new RestfulResponse<>(CommonEnum.SUCCESS.getCode(), CommonEnum.SUCCESS.getText(), null);
        try {
            List<LspInfo> lspInfo = lspInfoService.getLspInfoAll(lspInfos);
            result.setData(lspInfo);
        } catch (BaseException e) {
            LOGGER.error("CarrierController.getLspInfoAll ERROR {}", e);
            result = new RestfulResponse<>(CommonEnum.ERROR.getCode(), e.getMessage(), null);
        } catch (Exception e) {
            LOGGER.error("CarrierController.getLspInfoAll ERROR {}", e);
            result = new RestfulResponse<>(CommonEnum.ERROR.getCode(), CommonEnum.ERROR.getText(), null);
        }
        return result;
    }

    @PostMapping(value = "/queryLspByName")
    @ApiOperation(value = "根据应收款项获取承运商ids", notes = "根据应收款项获取承运商ids", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
    public RestfulResponse<Map<Long, Long>> queryLspByName(@RequestBody List<ArFundDTO> arFundDTOS) {
        LOGGER.info("LspController.queryLspByName param : {}", arFundDTOS);
        RestfulResponse<Map<Long, Long>> result = new RestfulResponse<>(CommonEnum.SUCCESS.getCode(), CommonEnum.SUCCESS.getText(), null);
        try {
            result.setData(lspInfoService.queryLspByName(arFundDTOS));
        } catch (BaseException e) {
            LOGGER.error("LspController.queryLspByName BaseException", e);
            result.setCode(CommonEnum.ERROR.getCode());
            result.setMessage(e.getMessage());
        } catch (Exception e) {
            LOGGER.error("LspController.queryLspByName ERROR", e);
            result.setCode(CommonEnum.ERROR.getCode());
            result.setMessage("查询异常");
        }
        return result;
    }

    @GetMapping("/queryUserInfo")
    @ApiOperation(value = "获取登录用户信息", notes = "获取登录用户信息", produces = MediaType.APPLICATION_JSON_VALUE)
    public RestfulResponse<UserInfoVO> queryUserInfo(@RequestParam String phone) {
        LOGGER.info("LspController.queryUserInfo param : {}", phone);
        RestfulResponse<UserInfoVO> result = new RestfulResponse<>(CommonEnum.SUCCESS.getCode(), CommonEnum.SUCCESS.getText(), null);
        try {
            result.setData(lspInfoService.queryUserInfo(phone));
        } catch (BaseException e) {
            LOGGER.error("LspController.queryUserInfo BaseException", e);
            result.setCode(CommonEnum.ERROR.getCode());
            result.setMessage(e.getMessage());
        } catch (Exception e) {
            LOGGER.error("LspController.queryUserInfo ERROR", e);
            result.setCode(CommonEnum.ERROR.getCode());
            result.setMessage("查询异常");
        }
        return result;
    }

    @RequestMapping(value ="/queryUserOpenId", method = RequestMethod.POST)
    @ApiOperation(value = "获取登录用户openId和手机号", notes = "获取登录用户openId和手机号", produces = MediaType.APPLICATION_JSON_VALUE)
    public RestfulResponse<Map<String,Object>> queryUserOpenId(@RequestBody String mobile) {
        LOGGER.info("LspController.queryUserOpenId param : {}", mobile);
        RestfulResponse<Map<String,Object>> result = new RestfulResponse<>(CommonEnum.SUCCESS.getCode(), CommonEnum.SUCCESS.getText(), null);
        try {
            result.setData(lspInfoService.queryUserOpenId(mobile));
        } catch (BaseException e) {
            LOGGER.error("LspController.queryUserOpenId BaseException", e);
            result.setCode(CommonEnum.ERROR.getCode());
            result.setMessage(e.getMessage());
        } catch (Exception e) {
            LOGGER.error("LspController.queryUserOpenId ERROR", e);
            result.setCode(CommonEnum.ERROR.getCode());
            result.setMessage("查询异常");
        }
        return result;
    }

    @PostMapping(value = "/addOpenId")
    @ApiOperation(value = "添加用户微信openId", notes = "添加用户微信openId", produces = MediaType.APPLICATION_JSON_VALUE, response = RestfulResponse.class)
    public RestfulResponse<String> addOpenId(@RequestBody User user) {
        LOGGER.info("CarrierController.addOpenId（添加用户微信openId） params : {} ", user);
        RestfulResponse<String> result = new RestfulResponse<>(CommonEnum.SUCCESS.getCode(), CommonEnum.SUCCESS.getText(),null);
        try {
            result.setData(lspInfoService.addUserOpenId(user));
        } catch (BaseException e) {
            LOGGER.error("CarrierController.addOpenId ERROR... ", e);
            result = new RestfulResponse<>(CommonEnum.ERROR.getCode(), e.getMessage(), null);
        } catch (Exception e) {
            LOGGER.error("CarrierController.addOpenId ERROR... ", e);
            result = new RestfulResponse<>(CommonEnum.ERROR.getCode(), CommonEnum.ERROR.getText(), null);
        }
        return result;
    }


    @PostMapping(value = "/disableLspInfo")
    @ApiOperation(value = "禁用承运商", notes = "禁用承运商", produces = MediaType.APPLICATION_JSON_VALUE, response = RestfulResponse.class)
    public RestfulResponse<String> disableLsp(@RequestBody LspBasicVO condition,@RequestHeader("Authorization") String authorization) {
        LOGGER.info("LspController.disableLsp（禁用承运商） params : {} ", condition);
        RestfulResponse<String> result =new RestfulResponse<>(CommonEnum.SUCCESS.getCode(), CommonEnum.SUCCESS.getText(),null);
        try {
            result.setData(lspInfoService.disableLsp(condition,authorization));
        } catch (BaseException e) {
            LOGGER.error("LspController.disableLsp... ", e);
            result = new RestfulResponse<>(CommonEnum.ERROR.getCode(), e.getMessage(), null);
        } catch (Exception e) {
            LOGGER.error("LspController.disableLsp ERROR... ", e);
            result = new RestfulResponse<>(CommonEnum.ERROR.getCode(), CommonEnum.ERROR.getText(), null);
        }
        return result;
    }


    @PostMapping(value = "/enableLspInfo")
    @ApiOperation(value = "启用承运商", notes = "禁用承运商", produces = MediaType.APPLICATION_JSON_VALUE, response = RestfulResponse.class)
    public RestfulResponse<String> enableLspInfo(@RequestBody LspBasicVO condition) {
        LOGGER.info("LspController.enableLspInfo（禁用承运商） params : {} ", condition);
        RestfulResponse<String> result =new RestfulResponse<>(CommonEnum.SUCCESS.getCode(), CommonEnum.SUCCESS.getText(),null);
        try {
            result.setData(lspInfoService.enableLspInfo(condition));
        } catch (BaseException e) {
            LOGGER.error("LspController.enableLspInfo... ", e);
            result = new RestfulResponse<>(CommonEnum.ERROR.getCode(), e.getMessage(), null);
        } catch (Exception e) {
            LOGGER.error("LspController.enableLspInfo ERROR... ", e);
            result = new RestfulResponse<>(CommonEnum.ERROR.getCode(), CommonEnum.ERROR.getText(), null);
        }
        return result;
    }

}
